package com.primaryedu.ui.app.parentsch;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import com.primaryedu.R;
import com.primaryedu.bean.FunctionBean;
import com.primaryedu.ui.BaseActivity;
import com.primaryedu.ui.exercise.ExerciseActivity;
import com.primaryedu.widget.DragGridViewOlder;

/**
 * 家长学校
 *
 * @author jun.wang
 * @description
 * @data 2018年1月8日
 */
public class ParentSchoolActivity extends BaseActivity implements OnClickListener {
    private DragGridViewOlder gridView;
    private List<FunctionBean> functionList;
    ParentAdapter parentAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_parent_school);
    }

    @Override
    protected int BindLayout() {
        return R.layout.activity_parent_school;
    }

    @Override
    protected void initView() {
        ((TextView) findViewById(R.id.title)).setText("家长学校");
        findViewById(R.id.back).setOnClickListener(this);
        gridView = (DragGridViewOlder) this.findViewById(R.id.gridView);
    }

    @Override
    protected void initData() {
        functionList = new ArrayList<>();
        FunctionBean bean = new FunctionBean();
        functionList.add(bean);

        FunctionBean bean2 = new FunctionBean();
        functionList.add(bean2);

        FunctionBean bean3 = new FunctionBean();
        functionList.add(bean3);

        FunctionBean bean4 = new FunctionBean();
        functionList.add(bean4);

        gridView.setItems(functionList);
        parentAdapter = new ParentAdapter(this);
        gridView.setAdapter(parentAdapter);

        gridView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {

                Intent intent = null;
                switch (position) {

                    case 0://问卷调查
                        intent = new Intent(ParentSchoolActivity.this, QuestionSurveyActivity.class);
//				    intent = new Intent(ParentSchoolActivity.this,QuestionActivity.class) ;
                        startActivity(intent);
//					showToast("暂未开通，敬请期待！");
                        break;

                    case 1://活动投票
                        intent = new Intent(ParentSchoolActivity.this, VoteActivity.class);
                        startActivity(intent);
//					showToast("暂未开通，敬请期待！");
                        break;

                    case 2://家校共育
                        intent = new Intent(ParentSchoolActivity.this, ExerciseActivity.class);
//					intent.putExtra("columnId", "eef4acaf63ba47b48ce89bb5d5e07e50") ;
                        intent.putExtra("columnId", "6eafbda3c20b4e8d930e1655330dce25");
                        intent.putExtra("titleStr", "家校共育");
                        startActivity(intent);
                        break;

                    case 3://亲子交流
                        intent = new Intent(ParentSchoolActivity.this, ExerciseActivity.class);
//					intent.putExtra("columnId", "f765c7c6f33648a1b4a476e8f0531b6a") ;
                        intent.putExtra("columnId", "68a2490e804d47a1a2ae00e921c224a9");
                        intent.putExtra("titleStr", "亲子交流");
                        startActivity(intent);
                        break;

                    case 4:
                        intent = new Intent(ParentSchoolActivity.this, ExerciseActivity.class);
//					intent.putExtra("columnId", "9c7b751edb994450bcdd538458431f91") ;
                        intent.putExtra("columnId", "c6108e1eb6d9481f9676b5081b167b55");
                        intent.putExtra("titleStr", "德育天地");
                        startActivity(intent);
                        break;

                    case 5:
                        intent = new Intent(ParentSchoolActivity.this, ExerciseActivity.class);
//					intent.putExtra("columnId", "90b528424147472e88467f0c03b42dd0") ;
                        intent.putExtra("columnId", "b93fc890aacb414e84dd494820b6dee6");
                        intent.putExtra("titleStr", "助力小升初");
                        startActivity(intent);
                        break;

                    default:
                        break;
                }
            }
        });
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.back:
                finish();
                break;

            default:
                break;
        }
    }
}
